<?php
class image
{
	function image()
	{

	}

	public function save_image($from, $to)
	{
		$res = move_uploaded_file($from, $to);
		if ($res) return true; else return false;
	}

	public function create_thumb($img, $height)
	{
		$old = imagecreatefromjpeg($img);
		$old_w = imagesx($old);
		$old_h = imagesy($old);
		$ratio = $height/$old_h;
		$new_w = $old_w*$ratio;
		$new_h = $old_h*$ratio;
		$new = imagecreatetruecolor($new_w, $new_h);
		imagecopyresampled($new, $old, 0, 0, 0, 0, $new_w, $new_h, $old_w, $old_h);
		imagejpeg($new,$_SERVER['DOCUMENT_ROOT']."pictures/thumb_".basename($img),100);
		imagedestroy($old);
		imagedestroy($new);
		return true;
	}
}
$image = new image();

?>
